package com.hjh.gameforum.controller;

import com.hjh.gameforum.entity.UserProfile;
import com.hjh.gameforum.result.Result;
import com.hjh.gameforum.service.UserProfileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userhome")
@Tag(name = "用户主页", description = "用户主页相关操作")
@RequiredArgsConstructor
@Slf4j
public class UserHomeController {
    private final UserProfileService userProfileService;


    @GetMapping("/{userId}")
    @Operation(summary = "获取用户主页信息")
    public Result getUserProfile(@PathVariable int userId) {
        log.info("获取用户主页信息");
        UserProfile userProfile = userProfileService.getUserProfile(userId);
        return Result.success(userProfile);
    }

    @PutMapping("/{userId}")
    @Operation(summary = "更新用户主页信息")
    public Result updateUserProfile(@PathVariable int userId, @RequestParam String introduction) {
        log.info("更新用户主页信息");
        userProfileService.updateUserProfile(userId,introduction);
        return Result.success();
    }

}
